home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / tool_inc.zip / ATOI.INC < prev    next >
Text File  |  1989-06-02  |  1KB  |  52 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * converts ascii string to an integer value
  15.  * (tp3 dies on leading spaces but likes trailing.
  16.  *  tp4 likes leading spaces but dies on trailing!!)
  17.  *
  18.  *)
  19.  
  20. function atol (asc:  anystring): longint;
  21. var
  22.    i:             integer;
  23.    value:         longint;
  24.    num:           anystring;
  25.  
  26. begin
  27.    num := '';
  28.    for i := 1 to length(asc) do
  29.       if (asc[i] >= '0') and (asc[i] <= '9') then
  30.          num := num + asc[i];
  31.  
  32.    if length(num) = 0 then
  33.       value := 0
  34.    else
  35.       val(num, value, i);
  36.  
  37.    atol := value;
  38. end;
  39.  
  40.  
  41. function atoi (asc:  anystring): integer;
  42. begin
  43.    atoi := integer(atol(asc));
  44. end;
  45.  
  46. function atow (asc:  anystring): word;
  47. begin
  48.    atow := word(atol(asc) and $FFFF);
  49. end;
  50.  
  51.  
  52.